/*
 * Slider.hpp
 *
 *  Created on: 11-12-2010
 *      Author: Przemek
 */

#pragma once

#include "Container.hpp"
#include "Button.hpp"
#include "utils/RangedValue.hpp"

class Slider: public Container
{
	private:
		static const Dimension THUMB_SIZE;
		static const float TRACK_HEIGHT;
		RangedValue<int> value;
		Button* thumb;
		Vector startDraggingPoint;

	public:
		Slider(const RangedValue<int>& value);
		Slider(const Range<int>& range);

		void setValue(int value);
		int getValue() const;

		void draw(const ClipArea& clipArea);

	private:
		void initThumbButton();
		float getFractionValue(const int x) const;
		void setThumbPosition();

		void mousePressed(const MouseListener::EventArguments& arguments);
		void mouseDragged(const MouseListener::EventArguments& arguments);
		void mouseReleased(const MouseListener::EventArguments& arguments);
		void keyPressed(const KeyListener::EventArguments& arguments);
};
